package com.fox.domain.service.Impl;

import com.fox.domain.model.Money;
import com.fox.domain.service.DiscountPolicy;

import java.math.BigDecimal;


public class SimpleDiscountPolicy implements DiscountPolicy {
    private final Money threshold; // 满多少
    private final BigDecimal rate; // 折扣率，如 0.9 表示 9 折

    public SimpleDiscountPolicy(Money threshold, BigDecimal rate) {
        this.threshold = threshold;
        this.rate = rate;
    }

    @Override
    public Money calculateDiscountedAmount(Money originalAmount) {
        // 只做示例：如果 originalAmount >= threshold，则打折，否则原价返回
        if (originalAmount.greaterThanOrEqual(threshold)) {
            return originalAmount.multiply(rate);
        }
        return originalAmount;
    }
}